chore(logging): move device_id into Segment identity traits MONGOSH-2234#2450
Merged
chore(logging): move device_id into Segment identity traits MONGOSH-2234#2450
Conversation
gagik
commented
May 7, 2025
| this.currentUserId = message.userId ?? message.anonymousId; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| this.currentUserId = message.userId ?? message.anonymousId!; |
Contributor
Author
There was a problem hiding this comment.
Unfortunately because of the more derivative type I think TypeScript can no longer correctly resolve this scenario
addaleax
approved these changes
May 28, 2025
Collaborator
addaleax
left a comment
There was a problem hiding this comment.
Code changes LGTM, is there a ticket that should be attached to this?
163850a to
66e1d89
Compare
addaleax
reviewed
Jun 2, 2025
| export type MongoshAnalyticsIdentity = Omit< | ||
| SegmentIdentity, | ||
| 'context' | 'traits' | 'timestamp' | ||
| >; |
Collaborator
There was a problem hiding this comment.
[2025/06/02 10:17:26.877] src/cli-repl.ts(646,11): error TS2322: Type 'Analytics | undefined' is not assignable to type 'MongoshAnalytics | undefined'.
[2025/06/02 10:17:26.877] Type 'Analytics' is not assignable to type 'MongoshAnalytics'.
[2025/06/02 10:17:26.877] Types of property 'identify' are incompatible.
[2025/06/02 10:17:26.877] Type '({ userId, anonymousId, traits, context, timestamp, integrations, }: IdentifyParams, callback?: Callback | undefined) => void' is not assignable to type '(message: AnalyticsIdentifyMessage) => void'.
[2025/06/02 10:17:26.877] Types of parameters '__0' and 'message' are incompatible.
[2025/06/02 10:17:26.877] Type 'AnalyticsIdentifyMessage' is not assignable to type 'IdentifyParams'.
[2025/06/02 10:17:26.877] Type 'AnalyticsIdentifyMessage' is not assignable to type '{ traits?: UserTraits | undefined; context?: ExtraContext | undefined; timestamp?: Timestamp | undefined; integrations?: Integrations | undefined; } & { ...; }'.
[2025/06/02 10:17:26.877] Type 'AnalyticsIdentifyMessage' is not assignable to type '{ userId?: string | undefined; anonymousId: string; }'.
[2025/06/02 10:17:26.877] Types of property 'anonymousId' are incompatible.
[2025/06/02 10:17:26.877] Type 'string | undefined' is not assignable to type 'string'.
[2025/06/02 10:17:26.877] Type 'undefined' is not assignable to type 'string'.
ae019cb to
de74a6f
Compare
6a195a3 to
3788ddd
Compare
addaleax
approved these changes
Jun 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Our track function was misleadingly typed with regards to Segment SDK.
For device_id to actually be used by Segment we'd need it to be in
traits.device_idin the identify function.This ties our types closer to the Segment SDK and moves the device ID to traits instead.